// 权限关联的菜单列表
export const MenuList = [
	{ name: '工作台', id: 1, menu: '/index/workbench' },
	{ name: '运营管理', id: 2, menu: '/index/operations' },
	{ name: '会话管理', id: 3, menu: '/index/sessions' },
	{ name: '业务记录管理', id: 4, menu: '/index/quality' },
	{ name: '坐席管理', id: 5, menu: '/index/agent' },
	{ name: '分组管理', id: 6, menu: '/index/group' },
	{ name: '表单管理', id: 7, menu: '/index/form' },
	{ name: '业务场景管理', id: 8, menu: '/index/scene' },
	{ name: '通话规则', id: 9, menu: '/index/work' },
	{ name: '系统配置', id: 10, menu: '/index/system' },
	{ name: '账号及权限', id: 11, menu: '/index/role' },
	{ name: '日志', id: 12, menu: '/index/dailyRecord' },
	{ name: '黑名单管理', id: 13, menu: '/index/blacklist' },
	{ name: '标签管理', id: 14, menu: '/index/labels' },
	{ name: '知识库管理', id: 16, menu: '/index/knowledgeBase' },
];

// 初始化角色的菜单权限
export const RolePermission = {
	admin: ['home', 'operations', 'sessions', 'quality', 'agent', 'group', 'form', 'scene', 'work', 'system', 'dailyRecord', 'role', 'blacklist', 'labels', 'knowledgeBase'],
	robot: ['workbench'],
	agent: ['workbench']
};

// resource 与菜单的对应关系
export const ResourceMap = {
	1: 'workbench',
	2: 'operations',
	3: 'sessions',
	4: 'quality',
	5: 'agent',
	6: 'group',
	7: 'form',
	8: 'scene',
	9: 'work',
	10: 'system',
	11: 'role',
	12: 'dailyRecord',
	13: 'blacklist',
	14: 'labels',
	16: 'knowledgeBase'

};

// 判断是否在菜单列表中
export const isInMenuList = path => {
	return MenuList.find(item => path && path.includes(item.menu));
};

// 判断是否在权限列表中
export const isInPermissinList = name => {
	const permission = localStorage.getItem(`zco_route_permission_${window.uid}`) || '';
	return JSON.parse(permission).find(item => name.includes(item));
};
